import axios from 'axios'

const app = {
    state: {
        flag: '123',
        flag2: '1234',
        list: []
    },
    mutations: {
        CHANG_FLAG: (state, number) => state.flag = number,
        INIT_LIST: (state, list) => state.list = list
    },
    actions: {
        ChangeFlage: ({commit}, {number}) => commit('CHANG_FLAG', number),
        getList(context) {
            setTimeout(function () {
                axios.get('/page.json').then(({data}) => {
                    console.log(data)
                    context.commit('INIT_LIST', data)
                })
                console.log('定时器1秒')
            }, 1000)
        }
    },
    getters: {getFlag: state => state.flag}
}
export default app;
